package com.yaoyong.codegenerator.config;

import com.yaoyong.codegenerator.properties.DatabaseProperties;
import com.yaoyong.codegenerator.properties.PathProperties;
import com.yaoyong.codegenerator.properties.ProjectProperties;
import com.yaoyong.codegenerator.utils.CodeUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(value = {DatabaseProperties.class, PathProperties.class, ProjectProperties.class})
@ConditionalOnClass(value = {CodeUtil.class})
@ConditionalOnProperty(prefix = "code.generator.auto-code", value = "enabled", matchIfMissing = true)
public class CodeUtilAutoConfig {


    @Bean
    @ConditionalOnMissingBean(value = {CodeUtil.class})
    public CodeUtil codeUtil() {
        return new CodeUtil();
    }
}
